package model.dao;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import model.entity.Album;
import model.entity.User;

@Stateless
@Remote(Init.class)
public class InitBean implements Init {

	@PersistenceContext(unitName = "Epics")
	EntityManager em;
	
	public void init() {
		User user=new User();
		user.setEmail("a@a.com");
		user.setPassword("a");
		user.setFirstName("Petar");
		user.setLastName("Petrovic");
		em.persist(user);
		Album favoriteAlbum=new Album();
		favoriteAlbum.setTitle("fav"+user.getId());
		favoriteAlbum.setFavorite(true);
		user.setFavorite(favoriteAlbum);
		favoriteAlbum.setUser(user);
		em.persist(favoriteAlbum);
		em.merge(user);
	}
}